//
//  ZQAddAdressPage.m
//  jianzhik
//
//  Created by huami on 2018/8/29.
//  Copyright © 2018年 WKWebView. All rights reserved.
//

#import "ZQAddAdressPage.h"
#import "ZQAFHelper.h"
#import "UIView+zq_extension.h"
#import "BRPickerView.h"
@interface ZQAddAdressPage ()




@end

@implementation ZQAddAdressPage

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"添加地址";
    [self.footButton setTitle:@"保存设置" forState:UIControlStateNormal];
    [self.view addSubview:self.footButton];
    [self.footButton addTarget:self action:@selector(addAdress) forControlEvents:UIControlEventTouchUpInside];
    [self.bTypeBtn setTitle:[ZQDataManger shareIntance].bTypeListArr.firstObject forState:UIControlStateNormal];
}

- (void)addAdress
{
    
    if (self.addressTextField.text.length == 0) {
        [UIHelper showTipsWithText:@"地址不能为空" inView:self.view];
        return;
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    parameters[@"Symbol"] = [[self.bTypeBtn currentTitle] uppercaseString]; ;
    parameters[@"Address"] = self.addressTextField.text;
                            
    [ZQAFHelper afnetworkRequestWithPostURL:@"/v1/user/addaddress" parameters:parameters view:self.view finishedBlcok:^(NSDictionary *dict) {
        [UIHelper showSuccessMessage:dict[@"Msg"] afterHideHud:2 toView:self.view completion:^{
            [self.navigationController popViewControllerAnimated:YES];
        }];
    }];

}

- (IBAction)selectBtnClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    
 
    [BRStringPickerView showStringPickerWithTitle:@"币种" dataSource:[ZQDataManger shareIntance].bTypeListArr defaultSelValue:[sender currentTitle] isAutoSelect:YES themeColor:kTinColor resultBlock:^(id selectValue) {
        //        textField.text = self.infoModel.educationStr = selectValue;
        [self.bTypeBtn setTitle:selectValue forState:UIControlStateNormal];
    } cancelBlock:^{
        NSLog(@"点击了背景视图或取消按钮");
    }];
}


@end
